﻿using System;
using System.Diagnostics;
using System.Threading;

namespace _031.多线程
{
	internal class Program
	{
		static void Main(string[] args)
		{
			// 子线程
			//ThreadStart threadStart = new ThreadStart(ChildThreadMethod);
			//Thread thread = new Thread(threadStart);

			Thread childThread = new Thread(new ThreadStart(ChildThreadMethod));
			childThread.Start();

			// 标志位
			isRun = false;

			// 线程中断任务
			//childThread.Abort();
			//主线程
			while (true)
			{
				Console.WriteLine("Main Thread - 聊天中....");
				Thread.Sleep(1);
			}

			
		}

		private static bool isRun = true;
		private static void ChildThreadMethod()
		{
			while (isRun)
			{
				Console.WriteLine("Child Thread - 听歌中....");
				Thread.Sleep(1);
			}
		}
	}
}
